import { reqAddressInfo, reqUserShopList } from '../../api'

const state = {
  userAddressInfo: [],
  userShopList: {}
}

const mutations = {
  GETUSERADDRESSINFO(state, userAddressInfo) {
    state.userAddressInfo = userAddressInfo
  },
  GETUSERSHOPLIST(state, userShopList){
    state.userShopList = userShopList
  }
}

const actions = {
  // 获取用户地址信息
  async getUserAddressInfo({ commit }) {
    let result = await reqAddressInfo()
    // console.log(result);
    if (result.code == 200) {
      commit('GETUSERADDRESSINFO', result.data)
    }
  },

  // 获取用户购买商品清单
  async getUserShopList({commit}){
    let result = await reqUserShopList()
    // console.log(result);
    if (result.code == 200){
      commit('GETUSERSHOPLIST', result.data)
    }
  }

}

const getters = {}

export default {
  state,
  mutations,
  actions,
  getters,
}
